|
Inline formatting The examined way of formatting can be applied to any of the expressions, located in the object. In our case, everything works correctly because there is only one expression in the object. However, if we have two expressions and, in addition, they are of different types? Let us examine the following case: the total and number of orders displaying in one object. To perform this, the following text must be placed into the object: Total: [SUM(<Group."ItemsTotal">,MasterData1)] When starting, we can make sure that both of the values are presented in monetary format (which we have set in the previous example), which is rather incorrect:
To receive correct display of values, each of them should be formatted individually. To perform this, there are the so-called format tags. They are added before the closing square bracket of the expression. In our example, let us disable the object formatting (select the "Text (without formatting)" category in the format editor). Now we need to modify the format of the first variable, since the second will definitely be displayed correctly (without formatting, i.e. as the integer, and this would be exactly what we need). To perform this, let us modify the object text in the following way: Sum: [SUM(<Group."ItemsTotal">,MasterData1) #n%2,2m] And make sure that now the report works correctly:
Now let’s draw attention to use of tags. The general syntax is the following: [expression #tag] Note that space between the expression and the "#" sign is obligatory! The tag itself might look as follows: #nFormattingLine– the numerical format "FormattingLine" in every case is an argument for the function, with the help of which formatting is accomplished. Thus, for numerical formatting, such function would be the Delphi’s Format function, for date/time it is the FormatDateTime function. One can get the possible lines’ values from the Delphi help system. Below are several values used in FastReport: for the numerical formatting: for the date/time format: It is acceptable to place comma or dash instead of period in the line for the numerical format. In this case, this symbol will be used as a separator between the integer and the fractional parts of the figure. Usage of other separators is not acceptable. As for formatting of the "#b" type (boolean), the formatting line is presented as two values separated by comma. The first value corresponds to "False," the second one corresponds to "True." In order to avoid necessity to memorize all these tags and their meanings, there is a convenient resource for formatting insertion in the "Text" object editor. When clicking the |